<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">添加班组训练计划</div>
      </div>
      <!--  -->
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">班组:</div>
          <div class="x-pro-input">
            <el-select v-model="thcate" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in workgroupnew" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">训练时间:</div>
          <div class="x-pro-input">
            <el-date-picker v-model="traintime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日" value-format="yyyyMMdd" :disabled="isfromindex" :editable="notkey"></el-date-picker>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">训练内容:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="trainpro" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-gobtn" @click="isok" v-show="!isfromindex">提交</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var isback = api.pageParam.isbackshow;
    console.log(isback);
    var tid = api.pageParam.id;
    console.log(tid);
    var tdeptid = api.pageParam.deptid;
    console.log(tdeptid);
    var tindate = api.pageParam.indate;
    console.log(tindate);
    var tcontent = api.pageParam.content;
    console.log(tcontent);

    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          thisback:false,
          thid:'',
          isfromindex:false,
          thcate:'',
          traintime:'',
          trainpro:'',
          workgroupnew:'',
          notkey:false,
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.thisback = isback;
        if(that.thisback){
          that.thid = tid;
          that.thcate = tdeptid;
          that.traintime = tindate;
          that.trainpro = tcontent;
        }
        that.workgroupfun()

      },
      methods: {
        //工作组
        workgroupfun:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/dept',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.workgroupnew = ret.data.list;



              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        isok:function(){
          var that = this;
          api.ajax({
            url:baseurl+'api/meeting/addWeekTrain',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                deptid:that.thcate,
                date:that.traintime,
                content:that.trainpro,
                id:that.thid

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.alert({
                    title: '提交成功',
                    msg: '',
                }, function(ret, err) {

                });
                api.sendEvent({
                    name: 'addclasstrainplanok',
                    extra: {
                    
                    }
                });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },

      }
    })
	}


	</script>
</body>
</html>
